#!/bin/bash

#Compilation des applications
cd ./OntoApplications
ant compile
cd ..

#Copie des fichiers compilés et fractal des applications dans le projet OntoCompoFramework
compilrep='./OntoApplications/build/applications/'
apprep='./OntoCompoFramework/OntoApplications/applications/'

for file in `ls $apprep`
    do
	echo "rm -r $apprep$file"
	rm -r $apprep$file
done

echo "cp -R ${compilrep}* $apprep"
cp -R ${compilrep}* $apprep

#Copie des fichiers semantiques dans le projet OntoCompoFramework
semanticrep='./OntoCompoSemantic/applications/'

for file in `ls $apprep`
    do
	lowercase=`echo $file | tr "[:upper:]" "[:lower:]"`
	for semfile in `ls $semanticrep`
	do
		semlowercase=`echo $semfile | tr "[:upper:]" "[:lower:]"`
		if [[ $lowercase == $semlowercase ]]
		then
			echo "mkdir $apprep$file/semantic"
			mkdir $apprep$file/semantic
			echo "cp $semanticrep$semfile/*.rdf $apprep$file/semantic/"
			cp $semanticrep$semfile/*.rdf $apprep$file/semantic/
		fi
	done
done